package com.house.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.house.common.pojo.EUDataGridResult;
import com.house.mapper.HousedoorMapper;
import com.house.pojo.Housedoor;
import com.house.pojo.HousedoorExample;

import com.house.pojo.HousedoorExample.Criteria;
import com.house.service.HousedoorService;

@Service
public class HousedoorServiceImpl implements HousedoorService {
	
	@Autowired
	private HousedoorMapper housedoorMapper;
	@Override
	public EUDataGridResult getDoorList(int page, int rows) {
		HousedoorExample example = new HousedoorExample();
		//设置分页
		PageHelper.startPage(page, rows);
		
		List<Housedoor> list = housedoorMapper.selectByExample(example);
		//取分页信息
		PageInfo<Housedoor> pageInfo = new PageInfo<>(list);

		EUDataGridResult result = new EUDataGridResult();
		result.setRows(list);
		result.setTotal(pageInfo.getTotal());
		return result;
	}
	
	
	@Override
	public int delete(List<Integer> id) {
		// TODO Auto-generated method stub
		HousedoorExample example = new HousedoorExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdIn(id);		
		return housedoorMapper.deleteByExample(example);
	}


	@Override
	public int add(Housedoor door) {
		// TODO Auto-generated method stub
		return housedoorMapper.insert(door);
	}

}
